﻿using System;
using System.Windows.Forms;

namespace TheRaces
{
    public class Greyhound
    {
        public int StartingPosition; // Where my PictureBox starts
        public int RacetrackLength; // How long the racetrack is
        public PictureBox MyPictureBox = null; // My PictureBox object
        public int Location = 0; // My Location on the racetrack
        public Random Randomizer; // An instance of Random
        public string Name;

        public bool Run()
        {
            // Move forward either 1,2,3,or 4 spaces at random
            // Update the position of my PictureBox on the form like this:
            // MyPictureBox.Left = StartingPosition + Location
            // Return if I won the race
            if (MyPictureBox != null)
            {
                Location = Randomizer.Next(1, 4);
                MyPictureBox.Left += StartingPosition + Location;
                return MyPictureBox.Left == RacetrackLength - MyPictureBox.Width;
            }
            return false;
        }

        public void TakeStartingPosition()
        {
            // Reset my location to 0 and my PictureBox to starting position
            Location = 0;
            MyPictureBox.Left = StartingPosition;
        }
    }
}
